<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>

<script type="text/javascript" language="javascript">
	function submitCostQuery(form, orderField, orderType){
		form.orderField.value = orderField;
		form.orderType.value = orderType;
		form.action = "costElementList.do";
		form.submit();
	}
</script>
<html:form action="/costElementList">
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
</html:form>
<table width="100%">
	<tr>
		<td>
			<table align="center" width="290" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
				<tr>
					<td width="50" class="titulocolumna" align="center"><html:link action="/createNewCostElement"><img alt="<bean:message key="common.add"/> <bean:message key="label.transports.query.pricePerCornUnit"/>" src="images/nuevo.gif" border="0"></html:link></td>
					<td width="70" class="titulocolumna" align="center">
						<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="COST" nombreCortoEnt="NEW" permiso="ADMINISTRACION"> 
							<a href="#>" onclick="submitCostQuery(document.CostElementListForm, 1, '<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="label.costelement.list.code"/>
								<c:choose>
									<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
										<img alt="<fmt:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
										<img alt="<fmt:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
							</a>
						</s:entidad>
					</td>
					<td width="150" class="titulocolumna" align="center">
						<a href="#>" onclick="submitCostQuery(document.CostElementListForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
							<bean:message key="label.costelement.list.description"/>
							<c:choose>
								<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
									<img alt="<fmt:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
								</c:when>
								<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
									<img alt="<fmt:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
								</c:when>
							</c:choose>
						</a>
					</td>
					<td width="20" class="titulocolumna" align="center">&nbsp;</td>
				</tr>
				<logic:notEmpty name="elementList">
					<logic:iterate id="costelements" name="elementList" indexId="int_i">
						<% 	java.util.HashMap mapa=new java.util.HashMap(0);%>
					<bean:define id="id" name="costelements" property="costElementID"></bean:define>
					<% 	mapa.put("ceId",id);
						request.setAttribute("mapa",mapa); 
					%> 
						<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">
							<td>
								<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="COST" nombreCortoEnt="EDIT" permiso="ADMINISTRACION">
									<logic:equal name="costelements" property="typeId" value="0">
										<html:link action="/showEditCostElement.do" paramId="costElementView.costElementID" paramName="costelements" paramProperty="costElementID"><img alt="<bean:message key="common.edit"/> <bean:write name="costelements" property="costElementCode"/>" src="images/modificar.gif" border="0"></html:link>
									</logic:equal>
								</s:entidad>
							</td>
							<td align="left"><bean:write name="costelements" property="costElementCode"/></td>
							<td align="left"><bean:write name="costelements" property="costElementDescription"/></td>
							<td align="center">
								<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="COST" nombreCortoEnt="DELETE" permiso="ADMINISTRACION">
									<logic:equal name="costelements" property="typeId" value="0">
										<a href="#>" onclick="if(confirmDelete('<bean:write name="costelements" property="costElementCode"/>'))location.href='costElementDelete.do?ceId=<bean:write name="costelements" property="costElementID"/>';">
											<img alt="<bean:message key="common.delete"/> <bean:write name="costelements" property="costElementCode"/>" src="images/eliminar.jpg" border="0">
										</a>
									</logic:equal>
								</s:entidad>
							</td>
						</tr>
					</logic:iterate>
				</logic:notEmpty>
			</table>
		</td>
	</tr>
</table>
<br />
<br />